package com.yurun.controller.admin;

import com.yurun.entity.Business;
import com.yurun.model.vo.Result;
import com.yurun.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin")
public class BusinessAdminController {
    @Autowired
    BusinessService businessService;
    /**
     * @Description: 后台-添加业务信息
     * @Param: business
     * @return: void
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @PostMapping("/business")
    public void addBusiness(@RequestBody Business business){
        businessService.addBusiness(business);
    }
    /**
     * @Description: 后台-通过ID-删除业务信息
     * @Param: id
     * @return: void
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @DeleteMapping("/business/id")
    public void deleteBusinessById(@RequestParam Long id){
        businessService.deleteBusinessById(id);
    }
    /**
     * @Description: 后台-通过业务名称-删除业务信息
     * @Param: name
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("/business/name")
    public Result getBusinessByName(@RequestParam String name){
        Business object=businessService.getBusinessByName(name);
        return Result.ok("获取业务信息成功",object);
    }
}
